#!/bin/bash

output_file="output/results.txt"

# 清空结果文件
> "$output_file"

# 编译和运行每个版本
for optimization in "" "-O1" "-O2"; do
  echo "Compiling with optimization level: $optimization" >> "$output_file"
  
  g++ main.cpp train.cpp guessing.cpp md5.cpp -o test.exe $optimization
  
  if [ $? -eq 0 ]; then
    echo "Running test.exe with optimization level: $optimization" >> "$output_file"
    ./test.exe >> "$output_file"
    echo "----------------------------------------" >> "$output_file"
  else
    echo "Compilation failed for optimization level: $optimization" >> "$output_file"
  fi
done